package com.hao.servlet;
import com.hao.entity.work;
import com.hao.service.workservice;
import com.hao.serviceImpl.workserviceImpl;


import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Administrator on 2018/8/9.
 */
public class addwork extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();

        work yy=new work();
        yy.setStaffid( Integer.parseInt(request.getParameter("staffid")));
        yy.setUserName(request.getParameter("userName"));
        yy.setUserPhone(request.getParameter("userPhone"));
        yy.setUserAddress(request.getParameter("userAddress"));
        yy.setWorkType( Integer.parseInt(request.getParameter("workType")));
        yy.setStatus( Integer.parseInt(request.getParameter("status")));
        yy.setWpid( Integer.parseInt(request.getParameter("wpid")));


        workservice vv=new workserviceImpl();
        int data=vv.add(yy);
       if(data>0){
           out.print("<script language='javascript'>history.go(-1);alert('新增成功',{icon: 6});</script>");
       }else{
           out.print("<script language='javascript'>history.go(-1);alert('新增失败');</script>");

       }

        out.flush();
        out.close();



    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
    }
}
